package it.uni.bo.monitoring.service;

public class StaticFields {

	public final static byte INB=0;
	public final static byte OUTB=1;
	public final static byte FAILB=2;

	public final static int DIR_B=1;
	public final static int SIZE_B=4;
	public final static int TIME_B=8;
	public final static int SESS_B=32;
	public final static int[] KEY_ELEM = {	DIR_B,
											SIZE_B,
											TIME_B,
											SESS_B
											};
	public final static int KEY_SIZE=		DIR_B		+
											SIZE_B		+
											TIME_B		+
											SESS_B
											;
	public final static int FAIL_DESC_B=4;
	public final static int SEQ_NUM_B=4;
	public final static int USER_LEN_B=4;
	public final static int PASS_LEN_B = 4;
	public final static int OPER_LEN_B=4;
	public final static int NS_LEN_B=4;
	public final static int APPL_URL_LEN_B=4;
	public final static int[] CONTENT_ELEM = {	SEQ_NUM_B,
												USER_LEN_B,
												PASS_LEN_B, 
												APPL_URL_LEN_B,
												NS_LEN_B,
												OPER_LEN_B
												};

	public final static int CONTENT_MIN_SIZE = 	SEQ_NUM_B		+
												USER_LEN_B 		+
												PASS_LEN_B 		+
												APPL_URL_LEN_B	+
												NS_LEN_B 		+
												OPER_LEN_B 		 
												;
	
	public final static int NUM_PAR_B=4;
	public final static int PAR_B=4;
	
	public final static int UDP_PORT = 9876;
	public final static int UDP_PACK_SIZE = 1024;
	
	
	public final static String SLANG_LANGUAGE="Slang";
	
	public final static String QUERY_SQL_EVENT="INSERT INTO Event (id_e, direction,timestamp, seq_number, session, application_id, user_id, ws_operation_id, ws_id) VALUES (?, ?, ?, ? ,?, ? ,?, ?, ?)";
	public final static String QUERY_SQL_EVENT_PARAMETER="INSERT INTO Event_Parameter (value,position,ws_operation_par_id,event_id) VALUES (?, ?, ? ,?)";
	public final static String QUERY_SQL_RAWDATA="INSERT INTO Raw_Data (id_key,content) VALUES (?, ?)";
	public final static String QUERY_SQL_VIOLATION="INSERT INTO Violation (componentName,sla_id,event_id,description) VALUES (?, ?, ?, ?)";
	public static final String QUERY_ALL_SLA="from Sla sla where sla.slaState = SOME(select idSlas FROM SlaState s where s.code= ?)";
	public static final String QUERY_SLA2="from Sla sla where sla.idSla = ?";
	public static final String QUERY_SLA3="from Sla sla where sla.application = ? AND sla.client = ? AND sla.slaState = SOME(select idSlas FROM SlaState s where s.code= ?)";
	public static final String QUERY_RAWDATA="from RawData rd where rd.idKey = ?";
	public static final String QUERY_ALL_RAWDATA="from RawData rd order by rd.idKey asc";
	public static final String QUERY_PAR="from WsOperationPar wop where wop.wsOperation = ? AND wop.mandatory = ? order by wop.position asc";
	public static final String QUERY_EVENT_INBOUND="from Event e where e.idE = ?";
	public static final String QUERY_EVENT="select count(*) from Event e where e.idE = ?";
	public static final String QUERY_TIME_EVENT="select count(*) from Event e where e.timestamp > ? and e.direction = ? and e.session = ?";
	public static final String QUERY_SEQUENCE_EVENT="select count(*) from Event e where e.seqNumber >= ? and e.direction= ? and e.application = ? and e.client = ? and e.wsOperation = ? and e.ws = ? and e.session = ?";
	public static final String QUERY_CLIENT="from Client u where u.username = ? AND u.password = ?";
	public static final String QUERY_APPLICATION="from Application a where a.appUrl = ?";
	public static final String QUERY_WS="from Ws w where w.namespace = ? AND w.idWs = SOME (select ws from WsByApplication wb where wb.application = ?)";
	public static final String QUERY_OPERATION="from WsOperation wo where wo.ws = ? AND wo.name = ?";
	public static final String QUERY_INTER="select count(*) FROM Client c join c.interlocutor i join i.intState s where c.idU= ? AND s.code= ?";
	
}
